package com.lsfb.signln.Statistics.WithoutDepNum;

import android.content.Context;
import android.view.View;
import android.widget.ProgressBar;

import com.lsfb.signln.R;
import com.zgscwjm.lsfbbasetemplate.adapter.CommonRecycAdapter;
import com.zgscwjm.lsfbbasetemplate.adapter.ViewHolderRecyc;

import java.util.List;

/**
 * Created by Administrator on 2018/3/1 0001.
 */

public class DepartSignStatisticsAdapter extends CommonRecycAdapter<DepartSignStatisticsBean.ListBean> {
    private Context mContext;
    private int count;

    public void setCount(int count) {
        if (count == 0) {
            count = 1;
        }
        this.count = count;
    }

    private ItemClickListen listen;

    public interface ItemClickListen {
        void onClick(DepartSignStatisticsBean.ListBean model);
    }

    public DepartSignStatisticsAdapter(Context context, List<DepartSignStatisticsBean.ListBean> list, int layoutId, ItemClickListen listen) {
        super(context, list, layoutId);
        mContext = context;
        this.listen = listen;
    }

    @Override
    public void convert(ViewHolderRecyc holder, final DepartSignStatisticsBean.ListBean model) {
        //部门名称
        holder.setText(R.id.item_text_depart, model.getName());
        ProgressBar progressBar = holder.getView(R.id.aty_nutrition_pb_dangu);
        progressBar.setMax(count);
//        int progress = Integer.parseInt(model.getCount()) / count;
        progressBar.setProgress(Integer.parseInt(model.getCount()));
        //部门外勤签到数
        holder.setText(R.id.item_text_depart_num, model.getCount());

        holder.setOnclick(R.id.item_main, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listen != null) {
                    listen.onClick(model);
                }
            }
        });
    }
}
